﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Remoting;

namespace Pixysoft.Framework.Comet
{
    [Remote("Pixysoft.Framework.Comet", "Pixysoft.Framework.Comet.Core.CometRemoting")]
    public interface ICometRemoting
    {
        /// <summary>
        /// 发送信息 
        /// 当目标不在线、信息是持久信息且目标长时间没有获取，则返回false 
        /// </summary>
        /// <param name="targetid"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        bool PostMessage(string senderCode, string receiverCode, string message);

        /// <summary>
        /// 发送数据 
        /// 当目标不在线、信息是持久信息且目标长时间没有获取，则返回false
        /// </summary>
        /// <returns></returns>
        bool PostData(bool persisted, ICometMessage message);

        /// <summary>
        /// 发送数据 
        /// 当目标不在线、信息是持久信息且目标长时间没有获取，则返回false
        /// </summary>
        /// <returns></returns>
        bool PostDatas(string receiverCode, bool persisted, ICometMessage[] messages);



        /// <summary>
        /// 判断对方是否在线
        /// </summary>
        /// <param name="targetId"></param>
        /// <returns></returns>
        bool IsOnline(string receiverCode);

        /// <summary>
        /// 清空数据
        /// </summary>
        /// <param name="senderCode"></param>
        /// <returns></returns>
        bool ClearDatas(string senderCode);

        /// <summary>
        /// 强迫目标下线 用于组播
        /// </summary>
        bool Offline(string receiverCode);



        /// <summary>
        /// 组下载 直接返回 没有comet
        /// </summary>
        /// <returns></returns>
        ICometMessage[] GetDatas(string senderCode);

        /// <summary>
        /// 如果超时 返回null
        /// </summary>
        /// <param name="senderCode"></param>
        /// <param name="receiverCode"></param>
        /// <returns></returns>
        ICometMessage GetCometMessage(string senderCode, string receiverCode);

        /// <summary>
        /// 发送同时持久
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        ICometMessage HoldCometMessage(string senderCode, string receiverCode, ICometMessage message);
    }
}

